<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
  <%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<script type="text/javascript" src="<%=basePath%>Js/jquery.js"></script>
<link rel="stylesheet" type="text/css" href="<%=basePath%>css/mycss/bootstrap.min.css" />
<link rel="stylesheet"
	href="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/css/bootstrap.min.css">
<script src="https://cdn.staticfile.org/jquery/2.1.1/jquery.min.js"></script>
<script
	src="https://cdn.staticfile.org/twitter-bootstrap/3.3.7/js/bootstrap.min.js"></script>
</head>

<script type="text/javascript">

function showVipMan(id){
	
	$.ajax({
		type:"post",
		url:"selectvip_managementByid.do",
		data:{
			"id":id,
		},
		success:function(result){
			stus = JSON.parse(result)
			var stu = "";
			
			for(var i = 0; i < stus.length; i++ ){
				
				stu += "<tr><td>会员等级</td>";
				stu += "<td><input type='text' value='"+stus[i].grade+"' class='form-control' id='grade' placeholder='请输入房型名称'>";
				stu +="<input value='"+stus[i].id+"' type='hidden' id='id' ></td></tr>"
				stu += "<tr><td>会员折扣</td>";
				stu += "<td><input type='text' value='"+stus[i].discounts+"' class='form-control' id='discounts' placeholder=''></td></tr>";
				stu += "<tr><td>升级金额</td>";
				stu += "<td><input type='text' value='"+stus[i].upgrade+"' class='form-control' id='upgrade' placeholder='请输入床位数'></td></tr>";
					
			}
			$("#inftable").html(stu);
			
			
		},
		error:function(){
			alert("系统故障")
		}
		
	})
}

function amendVipMan(){
	
	var id = $("#id").val();
	var grade = $("#grade").val();
	var discounts = $("#discounts").val();
	var upgrade = $("#upgrade").val();
	
	$.ajax({
		type:"post",
		url:"amendVipMan.do",
		data:{
			"id":id,
			"grade":grade,
			"discounts":discounts,
			"upgrade":upgrade,
		},
		dataType:"text",
		success:function(result){
			
			if(result == "1"){
				alert("修改成功")
				window.location.href=""
			}else{
				alert("修改失败")
			}
			
		},
		error:function(){
			alert("系统故障")
		}
		
	})
}

</script>

<body>

	<div style="border-width: 10px;border-color: beige;border-style: double;
		border-radius: -webkit-calc(background-color: );padding: 10px;margin:10px;left: 200px; top: 100px; width: 1180px;height: 520px">
<hr><h4 align="center" style="color: #4981F8;" align="center">会员卡升级管理</h4><hr><br><br>

<div style="position: absolute; left: 380px; top: 150px; width: 500px; height: 10px">
		<table class="table table-bordered">

			<tr>
				<th>会员等级</th>
				<th>会员折扣</th>
				<th>升级金额</th>
				<th>操作</th>
			</tr>
			<c:forEach items="${list}" var="viplist">
			<tr>
				<td>${viplist.grade}</td>
				<td>${viplist.discounts}</td>
				<td>${viplist.upgrade}</td>
				<td>
				<a href="#" onclick="showVipMan('${viplist.id}')" data-toggle="modal" data-target="#myModal">修改</a>
				</td>
				
			</tr>
			</c:forEach>

		</table>
</div>

	</div>
	
				<!-- 模态框（Modal） -->
		<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
			<div class="modal-dialog">
				<div class="modal-content">
					<div class="modal-header">
						<button type="button" class="close" data-dismiss="modal" aria-hidden="true">
							&times;
						</button>
					</div>
					<div id="myModalLabel">
					<table class="table table-bordered" id="inftable">
					
				</table>
					</div>
				
					   <div class="modal-footer">
						<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
					<button onclick="amendVipMan()" class="btn btn-success">修改</button>
					</div>
				</div><!-- /.modal-content -->
			</div><!-- /.modal -->
		</div>
	
	
</body>
</html>